#pragma once
#include < stdio.h >
#include < stdlib.h >
#include < windows.h >
#include "math.h"
#include < vcclr.h >
#include <conio.h>
#include "Scene.h"
#include "Selector.h"
#include "History.h"

namespace block_diagram_editor {

	using namespace System;
	using namespace System::ComponentModel;
	using namespace System::Collections;
	using namespace System::Windows::Forms;
	using namespace System::Data;
	using namespace System::Drawing;
	bool flALT = false;

	/// <summary>
	/// Summary for Form1
	///
	/// WARNING: If you change the name of this class, you will need to change the
	///          'Resource File Name' property for the managed resource compiler tool
	///          associated with all .resx files this class depends on.  Otherwise,
	///          the designers will not be able to interact properly with localized
	///          resources associated with this form.
	/// </summary>
	public ref class Form1 : public System::Windows::Forms::Form
	{
	public:
		Form1(void)
		{
			InitializeComponent();
			//
			//TODO: Add the constructor code here
			//
		}

	protected:
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		~Form1()
		{
			if (components)
			{
				delete components;
			}
		}

	protected: 

	protected: 
		Scene^ project; 
		Selector^ selected;
		History^ hist;
	private: System::Windows::Forms::ToolStripMenuItem^  fileToolStripMenuItem;
	private: System::Windows::Forms::ToolStripMenuItem^  editToolStripMenuItem;
	private: System::Windows::Forms::ToolStripMenuItem^  toolsToolStripMenuItem;
	private: System::Windows::Forms::ToolStripMenuItem^  helpToolStripMenuItem;
	private: System::Windows::Forms::ToolStripMenuItem^  openToolStripMenuItem;
	private: System::Windows::Forms::ToolStripMenuItem^  saveToolStripMenuItem;
	private: System::Windows::Forms::ToolStripMenuItem^  saveAsToolStripMenuItem;
	private: System::Windows::Forms::ToolStripMenuItem^  exportToolStripMenuItem;
	private: System::Windows::Forms::ToolStripMenuItem^  imageToolStripMenuItem;
	private: System::Windows::Forms::ToolStripMenuItem^  closeToolStripMenuItem;
	private: System::Windows::Forms::ToolStripMenuItem^  cutToolStripMenuItem;
	private: System::Windows::Forms::ToolStripMenuItem^  copyToolStripMenuItem;
	private: System::Windows::Forms::ToolStripMenuItem^  pasteToolStripMenuItem;
	private: System::Windows::Forms::ToolStripMenuItem^  deleteToolStripMenuItem;
	private: System::Windows::Forms::ToolStripMenuItem^  actionToolStripMenuItem;
	private: System::Windows::Forms::ToolStripMenuItem^  arrowToolStripMenuItem;
	private: System::Windows::Forms::ToolStripMenuItem^  actionToolStripMenuItem1;
	private: System::Windows::Forms::ToolStripMenuItem^  finishToolStripMenuItem;
	private: System::Windows::Forms::ToolStripMenuItem^  fAQToolStripMenuItem;
	private: System::Windows::Forms::ToolStripMenuItem^  aboutToolStripMenuItem;

	private: System::Windows::Forms::PictureBox^  imgSelected;
	private: System::Windows::Forms::PictureBox^  imgActive;
	private: System::Windows::Forms::PictureBox^  imgBuffer;
	private: int bufferType;
	private: int selectedType;
	private: int loaded;
	private: int tool;
	private: int linkType;
	private: int actionCurrent;
	private: int X;
	private: int Y;
	private: int resize_mod;
	private: int link_stat;
	private: char* file_name;

	private: System::Windows::Forms::Label^  currentEdit;

	private: System::Windows::Forms::OpenFileDialog^  openFileDialog1;
	private: System::Windows::Forms::SaveFileDialog^  saveFileDialog1;
	private: System::Windows::Forms::SaveFileDialog^  saveFileDialog2;

	private: System::Windows::Forms::StatusStrip^  statusStrip1;
	private: System::Windows::Forms::ToolStripStatusLabel^  toolStripStatusLabel1;
	private: System::Windows::Forms::ToolStripMenuItem^  toolStripMenuItem1;
	private: System::Windows::Forms::ToolStripMenuItem^  toolStripMenuItem3;

	private: System::Windows::Forms::ToolStripMenuItem^  toolStripMenuItem4;
	private: System::Windows::Forms::ToolStripMenuItem^  toolStripMenuItem5;
	private: System::Windows::Forms::ToolStripMenuItem^  jpegToolStripMenuItem;
	private: System::Windows::Forms::ToolStripMenuItem^  toolStripMenuItem6;
	private: System::Windows::Forms::ToolStripMenuItem^  toolStripMenuItem2;
	private: System::Windows::Forms::ToolStripMenuItem^  toolStripMenuItem9;
	private: System::Windows::Forms::ToolStripMenuItem^  toolStripMenuItem10;
	private: System::Windows::Forms::ToolStripMenuItem^  toolStripMenuItem11;
	private: System::Windows::Forms::ToolStripMenuItem^  toolStripMenuItem12;
	private: System::Windows::Forms::ToolStripMenuItem^  toolToolStripMenuItem;
	private: System::Windows::Forms::ToolStripMenuItem^  selecterToolStripMenuItem;
	private: System::Windows::Forms::ToolStripMenuItem^  linkerToolStripMenuItem;
	private: System::Windows::Forms::ToolStripMenuItem^  toolStripMenuItem16;
	private: System::Windows::Forms::ToolStripMenuItem^  startPointToolStripMenuItem;
	private: System::Windows::Forms::ToolStripMenuItem^  endToolStripMenuItem;
	private: System::Windows::Forms::ToolStripMenuItem^  signalToolStripMenuItem;
	private: System::Windows::Forms::ToolStripMenuItem^  signalReceiverToolStripMenuItem;
	private: System::Windows::Forms::ToolStripMenuItem^  multipleLinksToolStripMenuItem;
	private: System::Windows::Forms::ToolStripMenuItem^  multipleLinkshorzToolStripMenuItem;

	private: System::Windows::Forms::ToolStripMenuItem^  toolStripMenuItem8;
	private: System::Windows::Forms::ToolStripMenuItem^  toolStripMenuItem14;
	private: System::Windows::Forms::ToolStripMenuItem^  toolStripMenuItem15;
	private: System::Windows::Forms::MenuStrip^  menuStrip1;
	private: System::Windows::Forms::ToolStripPanel^  BottomToolStripPanel;
	private: System::Windows::Forms::ToolStripPanel^  TopToolStripPanel;
	private: System::Windows::Forms::ToolStripPanel^  RightToolStripPanel;
	private: System::Windows::Forms::ToolStripPanel^  LeftToolStripPanel;
	private: System::Windows::Forms::ToolStripContentPanel^  ContentPanel;
	private: System::Windows::Forms::ToolStrip^  toolStrip1;

	private: System::Windows::Forms::ToolStripButton^  toolSelecter;
	private: System::Windows::Forms::ToolStripButton^  toolLinker;
	private: System::Windows::Forms::ToolStripSeparator^  toolStripSeparator1;
	private: System::Windows::Forms::ToolStripButton^  toolStripButton1;
	private: System::Windows::Forms::ToolStripButton^  toolStripButton2;
	private: System::Windows::Forms::ToolStripButton^  toolStripButton3;
	private: System::Windows::Forms::ToolStripButton^  toolStripButton4;
	private: System::Windows::Forms::ToolStripButton^  toolStripButton5;
	private: System::Windows::Forms::ToolStripButton^  toolStripButton6;
	private: System::Windows::Forms::ToolStripButton^  toolStripButton7;



	private: System::Windows::Forms::ContextMenuStrip^  contextMenuStrip1;
	private: System::Windows::Forms::ToolStripMenuItem^  toolStripMenuItem17;
	private: System::Windows::Forms::ToolStripMenuItem^  toolStripMenuItem18;
	private: System::Windows::Forms::ToolStripMenuItem^  toolStripMenuItem19;
	private: System::Windows::Forms::ToolStripMenuItem^  toolStripMenuItem20;
	private: System::Windows::Forms::TextBox^  textBox;
private: System::Windows::Forms::PictureBox^  placer;
private: System::Windows::Forms::ToolStripMenuItem^  toolStripMenuItem13;
private: System::Windows::Forms::PictureBox^  pictureBox1;
private: System::Windows::Forms::ToolStripSeparator^  toolStripSeparator2;
private: System::Windows::Forms::ToolStripMenuItem^  undoToolStripMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^  redoToolStripMenuItem;
private: System::Windows::Forms::TrackBar^  trackBar1;


	private: System::ComponentModel::IContainer^  components;



	private:
		/// <summary>
		/// Required designer variable.
		/// </summary>


#pragma region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		void InitializeComponent(void)
		{
			this->components = (gcnew System::ComponentModel::Container());
			System::ComponentModel::ComponentResourceManager^  resources = (gcnew System::ComponentModel::ComponentResourceManager(Form1::typeid));
			this->contextMenuStrip1 = (gcnew System::Windows::Forms::ContextMenuStrip(this->components));
			this->toolStripMenuItem17 = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->toolStripMenuItem18 = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->toolStripMenuItem19 = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->toolStripMenuItem20 = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->openFileDialog1 = (gcnew System::Windows::Forms::OpenFileDialog());
			this->saveFileDialog1 = (gcnew System::Windows::Forms::SaveFileDialog());
			this->saveFileDialog2 = (gcnew System::Windows::Forms::SaveFileDialog());
			this->statusStrip1 = (gcnew System::Windows::Forms::StatusStrip());
			this->toolStripStatusLabel1 = (gcnew System::Windows::Forms::ToolStripStatusLabel());
			this->toolStripMenuItem1 = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->toolStripMenuItem3 = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->toolStripMenuItem4 = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->toolStripMenuItem5 = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->jpegToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->toolStripMenuItem6 = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->toolStripMenuItem2 = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->toolStripMenuItem9 = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->toolStripMenuItem10 = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->toolStripMenuItem11 = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->toolStripMenuItem12 = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->toolStripSeparator2 = (gcnew System::Windows::Forms::ToolStripSeparator());
			this->undoToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->redoToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->toolToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->selecterToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->linkerToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->toolStripMenuItem16 = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->startPointToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->endToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->signalToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->signalReceiverToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->multipleLinksToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->multipleLinkshorzToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->toolStripMenuItem8 = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->toolStripMenuItem14 = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->toolStripMenuItem15 = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->menuStrip1 = (gcnew System::Windows::Forms::MenuStrip());
			this->toolStripMenuItem13 = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->BottomToolStripPanel = (gcnew System::Windows::Forms::ToolStripPanel());
			this->TopToolStripPanel = (gcnew System::Windows::Forms::ToolStripPanel());
			this->RightToolStripPanel = (gcnew System::Windows::Forms::ToolStripPanel());
			this->LeftToolStripPanel = (gcnew System::Windows::Forms::ToolStripPanel());
			this->ContentPanel = (gcnew System::Windows::Forms::ToolStripContentPanel());
			this->toolStrip1 = (gcnew System::Windows::Forms::ToolStrip());
			this->toolSelecter = (gcnew System::Windows::Forms::ToolStripButton());
			this->toolLinker = (gcnew System::Windows::Forms::ToolStripButton());
			this->toolStripSeparator1 = (gcnew System::Windows::Forms::ToolStripSeparator());
			this->toolStripButton1 = (gcnew System::Windows::Forms::ToolStripButton());
			this->toolStripButton2 = (gcnew System::Windows::Forms::ToolStripButton());
			this->toolStripButton3 = (gcnew System::Windows::Forms::ToolStripButton());
			this->toolStripButton4 = (gcnew System::Windows::Forms::ToolStripButton());
			this->toolStripButton5 = (gcnew System::Windows::Forms::ToolStripButton());
			this->toolStripButton6 = (gcnew System::Windows::Forms::ToolStripButton());
			this->toolStripButton7 = (gcnew System::Windows::Forms::ToolStripButton());
			this->textBox = (gcnew System::Windows::Forms::TextBox());
			this->placer = (gcnew System::Windows::Forms::PictureBox());
			this->pictureBox1 = (gcnew System::Windows::Forms::PictureBox());
			this->trackBar1 = (gcnew System::Windows::Forms::TrackBar());
			this->contextMenuStrip1->SuspendLayout();
			this->statusStrip1->SuspendLayout();
			this->menuStrip1->SuspendLayout();
			this->toolStrip1->SuspendLayout();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->placer))->BeginInit();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->pictureBox1))->BeginInit();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->trackBar1))->BeginInit();
			this->SuspendLayout();
			// 
			// contextMenuStrip1
			// 
			this->contextMenuStrip1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(4) {this->toolStripMenuItem17, 
				this->toolStripMenuItem18, this->toolStripMenuItem19, this->toolStripMenuItem20});
			this->contextMenuStrip1->Name = L"contextMenuStrip1";
			this->contextMenuStrip1->Size = System::Drawing::Size(108, 92);
			// 
			// toolStripMenuItem17
			// 
			this->toolStripMenuItem17->Enabled = false;
			this->toolStripMenuItem17->Name = L"toolStripMenuItem17";
			this->toolStripMenuItem17->Size = System::Drawing::Size(107, 22);
			this->toolStripMenuItem17->Text = L"Cut";
			// 
			// toolStripMenuItem18
			// 
			this->toolStripMenuItem18->Enabled = false;
			this->toolStripMenuItem18->Name = L"toolStripMenuItem18";
			this->toolStripMenuItem18->Size = System::Drawing::Size(107, 22);
			this->toolStripMenuItem18->Text = L"Copy";
			// 
			// toolStripMenuItem19
			// 
			this->toolStripMenuItem19->Enabled = false;
			this->toolStripMenuItem19->Name = L"toolStripMenuItem19";
			this->toolStripMenuItem19->Size = System::Drawing::Size(107, 22);
			this->toolStripMenuItem19->Text = L"Paste";
			// 
			// toolStripMenuItem20
			// 
			this->toolStripMenuItem20->Name = L"toolStripMenuItem20";
			this->toolStripMenuItem20->Size = System::Drawing::Size(107, 22);
			this->toolStripMenuItem20->Text = L"Delete";
			this->toolStripMenuItem20->Click += gcnew System::EventHandler(this, &Form1::contextMenuDelete);
			// 
			// openFileDialog1
			// 
			this->openFileDialog1->AddExtension = false;
			this->openFileDialog1->Filter = L"My Diagramm (*.myd)|*.myd";
			// 
			// saveFileDialog1
			// 
			this->saveFileDialog1->AddExtension = false;
			this->saveFileDialog1->Filter = L"My Diagramm (*.myd)|*.myd";
			// 
			// saveFileDialog2
			// 
			this->saveFileDialog2->Filter = L"Jpeg (*.jpg)|*.jpg";
			// 
			// statusStrip1
			// 
			this->statusStrip1->BackgroundImage = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"statusStrip1.BackgroundImage")));
			this->statusStrip1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(1) {this->toolStripStatusLabel1});
			this->statusStrip1->Location = System::Drawing::Point(0, 463);
			this->statusStrip1->Name = L"statusStrip1";
			this->statusStrip1->Size = System::Drawing::Size(716, 22);
			this->statusStrip1->TabIndex = 93;
			this->statusStrip1->Text = L"statusStrip1";
			// 
			// toolStripStatusLabel1
			// 
			this->toolStripStatusLabel1->BackColor = System::Drawing::Color::Transparent;
			this->toolStripStatusLabel1->Name = L"toolStripStatusLabel1";
			this->toolStripStatusLabel1->Size = System::Drawing::Size(0, 17);
			// 
			// toolStripMenuItem1
			// 
			this->toolStripMenuItem1->BackColor = System::Drawing::Color::Transparent;
			this->toolStripMenuItem1->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(4) {this->toolStripMenuItem3, 
				this->toolStripMenuItem4, this->toolStripMenuItem5, this->toolStripMenuItem6});
			this->toolStripMenuItem1->ForeColor = System::Drawing::SystemColors::ControlLightLight;
			this->toolStripMenuItem1->Name = L"toolStripMenuItem1";
			this->toolStripMenuItem1->RightToLeft = System::Windows::Forms::RightToLeft::No;
			this->toolStripMenuItem1->Size = System::Drawing::Size(37, 20);
			this->toolStripMenuItem1->Text = L"File";
			// 
			// toolStripMenuItem3
			// 
			this->toolStripMenuItem3->BackColor = System::Drawing::SystemColors::ActiveCaptionText;
			this->toolStripMenuItem3->ForeColor = System::Drawing::SystemColors::ControlLightLight;
			this->toolStripMenuItem3->Name = L"toolStripMenuItem3";
			this->toolStripMenuItem3->Size = System::Drawing::Size(120, 22);
			this->toolStripMenuItem3->Text = L"Open..";
			this->toolStripMenuItem3->Click += gcnew System::EventHandler(this, &Form1::menuOpenFile);
			// 
			// toolStripMenuItem4
			// 
			this->toolStripMenuItem4->BackColor = System::Drawing::SystemColors::ActiveCaptionText;
			this->toolStripMenuItem4->ForeColor = System::Drawing::SystemColors::ControlLightLight;
			this->toolStripMenuItem4->Name = L"toolStripMenuItem4";
			this->toolStripMenuItem4->Size = System::Drawing::Size(120, 22);
			this->toolStripMenuItem4->Text = L"Save As..";
			this->toolStripMenuItem4->Click += gcnew System::EventHandler(this, &Form1::menuSaveFile);
			// 
			// toolStripMenuItem5
			// 
			this->toolStripMenuItem5->BackColor = System::Drawing::SystemColors::ActiveCaptionText;
			this->toolStripMenuItem5->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(1) {this->jpegToolStripMenuItem});
			this->toolStripMenuItem5->ForeColor = System::Drawing::SystemColors::ControlLightLight;
			this->toolStripMenuItem5->Name = L"toolStripMenuItem5";
			this->toolStripMenuItem5->Size = System::Drawing::Size(120, 22);
			this->toolStripMenuItem5->Text = L"Export";
			// 
			// jpegToolStripMenuItem
			// 
			this->jpegToolStripMenuItem->BackColor = System::Drawing::Color::Black;
			this->jpegToolStripMenuItem->ForeColor = System::Drawing::Color::White;
			this->jpegToolStripMenuItem->Name = L"jpegToolStripMenuItem";
			this->jpegToolStripMenuItem->Size = System::Drawing::Size(104, 22);
			this->jpegToolStripMenuItem->Text = L"Jpeg..";
			this->jpegToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::menuExportJpg);
			// 
			// toolStripMenuItem6
			// 
			this->toolStripMenuItem6->BackColor = System::Drawing::SystemColors::ActiveCaptionText;
			this->toolStripMenuItem6->ForeColor = System::Drawing::SystemColors::ControlLightLight;
			this->toolStripMenuItem6->Name = L"toolStripMenuItem6";
			this->toolStripMenuItem6->Size = System::Drawing::Size(120, 22);
			this->toolStripMenuItem6->Text = L"Close";
			this->toolStripMenuItem6->Click += gcnew System::EventHandler(this, &Form1::menuClose);
			// 
			// toolStripMenuItem2
			// 
			this->toolStripMenuItem2->BackColor = System::Drawing::Color::Transparent;
			this->toolStripMenuItem2->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(7) {this->toolStripMenuItem9, 
				this->toolStripMenuItem10, this->toolStripMenuItem11, this->toolStripMenuItem12, this->toolStripSeparator2, this->undoToolStripMenuItem, 
				this->redoToolStripMenuItem});
			this->toolStripMenuItem2->ForeColor = System::Drawing::SystemColors::ControlLightLight;
			this->toolStripMenuItem2->Name = L"toolStripMenuItem2";
			this->toolStripMenuItem2->Size = System::Drawing::Size(39, 20);
			this->toolStripMenuItem2->Text = L"Edit";
			// 
			// toolStripMenuItem9
			// 
			this->toolStripMenuItem9->BackColor = System::Drawing::SystemColors::ActiveCaptionText;
			this->toolStripMenuItem9->Enabled = false;
			this->toolStripMenuItem9->ForeColor = System::Drawing::SystemColors::ControlLightLight;
			this->toolStripMenuItem9->Name = L"toolStripMenuItem9";
			this->toolStripMenuItem9->Size = System::Drawing::Size(107, 22);
			this->toolStripMenuItem9->Text = L"Cut";
			this->toolStripMenuItem9->Click += gcnew System::EventHandler(this, &Form1::menuCut);
			// 
			// toolStripMenuItem10
			// 
			this->toolStripMenuItem10->BackColor = System::Drawing::SystemColors::ActiveCaptionText;
			this->toolStripMenuItem10->Enabled = false;
			this->toolStripMenuItem10->ForeColor = System::Drawing::SystemColors::ControlLightLight;
			this->toolStripMenuItem10->Name = L"toolStripMenuItem10";
			this->toolStripMenuItem10->Size = System::Drawing::Size(107, 22);
			this->toolStripMenuItem10->Text = L"Copy";
			this->toolStripMenuItem10->Click += gcnew System::EventHandler(this, &Form1::menuCopy);
			// 
			// toolStripMenuItem11
			// 
			this->toolStripMenuItem11->BackColor = System::Drawing::SystemColors::ActiveCaptionText;
			this->toolStripMenuItem11->Enabled = false;
			this->toolStripMenuItem11->ForeColor = System::Drawing::SystemColors::ControlLightLight;
			this->toolStripMenuItem11->Name = L"toolStripMenuItem11";
			this->toolStripMenuItem11->Size = System::Drawing::Size(107, 22);
			this->toolStripMenuItem11->Text = L"Paste";
			this->toolStripMenuItem11->Click += gcnew System::EventHandler(this, &Form1::menuPaste);
			// 
			// toolStripMenuItem12
			// 
			this->toolStripMenuItem12->BackColor = System::Drawing::SystemColors::ActiveCaptionText;
			this->toolStripMenuItem12->ForeColor = System::Drawing::SystemColors::ControlLightLight;
			this->toolStripMenuItem12->Name = L"toolStripMenuItem12";
			this->toolStripMenuItem12->Size = System::Drawing::Size(107, 22);
			this->toolStripMenuItem12->Text = L"Delete";
			this->toolStripMenuItem12->Click += gcnew System::EventHandler(this, &Form1::menuDelete);
			// 
			// toolStripSeparator2
			// 
			this->toolStripSeparator2->BackColor = System::Drawing::Color::Black;
			this->toolStripSeparator2->ForeColor = System::Drawing::Color::White;
			this->toolStripSeparator2->Name = L"toolStripSeparator2";
			this->toolStripSeparator2->Size = System::Drawing::Size(104, 6);
			// 
			// undoToolStripMenuItem
			// 
			this->undoToolStripMenuItem->BackColor = System::Drawing::Color::Black;
			this->undoToolStripMenuItem->ForeColor = System::Drawing::Color::White;
			this->undoToolStripMenuItem->Name = L"undoToolStripMenuItem";
			this->undoToolStripMenuItem->Size = System::Drawing::Size(107, 22);
			this->undoToolStripMenuItem->Text = L"Undo";
			this->undoToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::DoUndo);
			// 
			// redoToolStripMenuItem
			// 
			this->redoToolStripMenuItem->BackColor = System::Drawing::Color::Black;
			this->redoToolStripMenuItem->ForeColor = System::Drawing::Color::White;
			this->redoToolStripMenuItem->Name = L"redoToolStripMenuItem";
			this->redoToolStripMenuItem->Size = System::Drawing::Size(107, 22);
			this->redoToolStripMenuItem->Text = L"Redo";
			this->redoToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::DoRedo);
			// 
			// toolToolStripMenuItem
			// 
			this->toolToolStripMenuItem->BackColor = System::Drawing::Color::Transparent;
			this->toolToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(9) {this->selecterToolStripMenuItem, 
				this->linkerToolStripMenuItem, this->toolStripMenuItem16, this->startPointToolStripMenuItem, this->endToolStripMenuItem, this->signalToolStripMenuItem, 
				this->signalReceiverToolStripMenuItem, this->multipleLinksToolStripMenuItem, this->multipleLinkshorzToolStripMenuItem});
			this->toolToolStripMenuItem->ForeColor = System::Drawing::SystemColors::ControlLightLight;
			this->toolToolStripMenuItem->Name = L"toolToolStripMenuItem";
			this->toolToolStripMenuItem->Size = System::Drawing::Size(43, 20);
			this->toolToolStripMenuItem->Text = L"Tool";
			// 
			// selecterToolStripMenuItem
			// 
			this->selecterToolStripMenuItem->BackColor = System::Drawing::SystemColors::ActiveCaptionText;
			this->selecterToolStripMenuItem->ForeColor = System::Drawing::SystemColors::ControlLightLight;
			this->selecterToolStripMenuItem->Name = L"selecterToolStripMenuItem";
			this->selecterToolStripMenuItem->Size = System::Drawing::Size(179, 22);
			this->selecterToolStripMenuItem->Text = L"Selecter";
			this->selecterToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::menuToolSelecter);
			// 
			// linkerToolStripMenuItem
			// 
			this->linkerToolStripMenuItem->BackColor = System::Drawing::SystemColors::ActiveCaptionText;
			this->linkerToolStripMenuItem->ForeColor = System::Drawing::SystemColors::ControlLightLight;
			this->linkerToolStripMenuItem->Name = L"linkerToolStripMenuItem";
			this->linkerToolStripMenuItem->Size = System::Drawing::Size(179, 22);
			this->linkerToolStripMenuItem->Text = L"Linker";
			this->linkerToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::menuToolLinker);
			// 
			// toolStripMenuItem16
			// 
			this->toolStripMenuItem16->BackColor = System::Drawing::SystemColors::ActiveCaptionText;
			this->toolStripMenuItem16->ForeColor = System::Drawing::SystemColors::ControlLightLight;
			this->toolStripMenuItem16->Name = L"toolStripMenuItem16";
			this->toolStripMenuItem16->Size = System::Drawing::Size(179, 22);
			this->toolStripMenuItem16->Text = L"Action";
			this->toolStripMenuItem16->Click += gcnew System::EventHandler(this, &Form1::menuNewAction);
			// 
			// startPointToolStripMenuItem
			// 
			this->startPointToolStripMenuItem->BackColor = System::Drawing::SystemColors::ActiveCaptionText;
			this->startPointToolStripMenuItem->ForeColor = System::Drawing::SystemColors::ControlLightLight;
			this->startPointToolStripMenuItem->Name = L"startPointToolStripMenuItem";
			this->startPointToolStripMenuItem->Size = System::Drawing::Size(179, 22);
			this->startPointToolStripMenuItem->Text = L"Start point";
			this->startPointToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::menuNewStart);
			// 
			// endToolStripMenuItem
			// 
			this->endToolStripMenuItem->BackColor = System::Drawing::SystemColors::ActiveCaptionText;
			this->endToolStripMenuItem->ForeColor = System::Drawing::SystemColors::ControlLightLight;
			this->endToolStripMenuItem->Name = L"endToolStripMenuItem";
			this->endToolStripMenuItem->Size = System::Drawing::Size(179, 22);
			this->endToolStripMenuItem->Text = L"End point";
			this->endToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::menuNewEnd);
			// 
			// signalToolStripMenuItem
			// 
			this->signalToolStripMenuItem->BackColor = System::Drawing::SystemColors::ActiveCaptionText;
			this->signalToolStripMenuItem->ForeColor = System::Drawing::SystemColors::ControlLightLight;
			this->signalToolStripMenuItem->Name = L"signalToolStripMenuItem";
			this->signalToolStripMenuItem->Size = System::Drawing::Size(179, 22);
			this->signalToolStripMenuItem->Text = L"Signal receiver";
			this->signalToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::menuNewSignal);
			// 
			// signalReceiverToolStripMenuItem
			// 
			this->signalReceiverToolStripMenuItem->BackColor = System::Drawing::SystemColors::ActiveCaptionText;
			this->signalReceiverToolStripMenuItem->ForeColor = System::Drawing::SystemColors::ControlLightLight;
			this->signalReceiverToolStripMenuItem->Name = L"signalReceiverToolStripMenuItem";
			this->signalReceiverToolStripMenuItem->Size = System::Drawing::Size(179, 22);
			this->signalReceiverToolStripMenuItem->Text = L"Time signal";
			this->signalReceiverToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::menuNewSignalRecv);
			// 
			// multipleLinksToolStripMenuItem
			// 
			this->multipleLinksToolStripMenuItem->BackColor = System::Drawing::SystemColors::ActiveCaptionText;
			this->multipleLinksToolStripMenuItem->ForeColor = System::Drawing::SystemColors::ControlLightLight;
			this->multipleLinksToolStripMenuItem->Name = L"multipleLinksToolStripMenuItem";
			this->multipleLinksToolStripMenuItem->Size = System::Drawing::Size(179, 22);
			this->multipleLinksToolStripMenuItem->Text = L"Multiple links (vert)";
			this->multipleLinksToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::menuNewMult);
			// 
			// multipleLinkshorzToolStripMenuItem
			// 
			this->multipleLinkshorzToolStripMenuItem->BackColor = System::Drawing::SystemColors::ActiveCaptionText;
			this->multipleLinkshorzToolStripMenuItem->ForeColor = System::Drawing::SystemColors::ControlLightLight;
			this->multipleLinkshorzToolStripMenuItem->Name = L"multipleLinkshorzToolStripMenuItem";
			this->multipleLinkshorzToolStripMenuItem->Size = System::Drawing::Size(179, 22);
			this->multipleLinkshorzToolStripMenuItem->Text = L"Multiple links (horz)";
			this->multipleLinkshorzToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::menuNewMultH);
			// 
			// toolStripMenuItem8
			// 
			this->toolStripMenuItem8->BackColor = System::Drawing::Color::Transparent;
			this->toolStripMenuItem8->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(2) {this->toolStripMenuItem14, 
				this->toolStripMenuItem15});
			this->toolStripMenuItem8->Enabled = false;
			this->toolStripMenuItem8->ForeColor = System::Drawing::SystemColors::ControlLightLight;
			this->toolStripMenuItem8->Name = L"toolStripMenuItem8";
			this->toolStripMenuItem8->Size = System::Drawing::Size(44, 20);
			this->toolStripMenuItem8->Text = L"Help";
			// 
			// toolStripMenuItem14
			// 
			this->toolStripMenuItem14->BackColor = System::Drawing::SystemColors::ActiveCaptionText;
			this->toolStripMenuItem14->Enabled = false;
			this->toolStripMenuItem14->ForeColor = System::Drawing::SystemColors::ControlLightLight;
			this->toolStripMenuItem14->Name = L"toolStripMenuItem14";
			this->toolStripMenuItem14->Size = System::Drawing::Size(107, 22);
			this->toolStripMenuItem14->Text = L"FAQ";
			// 
			// toolStripMenuItem15
			// 
			this->toolStripMenuItem15->BackColor = System::Drawing::SystemColors::ActiveCaptionText;
			this->toolStripMenuItem15->Enabled = false;
			this->toolStripMenuItem15->ForeColor = System::Drawing::SystemColors::ControlLightLight;
			this->toolStripMenuItem15->Name = L"toolStripMenuItem15";
			this->toolStripMenuItem15->Size = System::Drawing::Size(107, 22);
			this->toolStripMenuItem15->Text = L"About";
			// 
			// menuStrip1
			// 
			this->menuStrip1->BackgroundImage = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"menuStrip1.BackgroundImage")));
			this->menuStrip1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(5) {this->toolStripMenuItem13, 
				this->toolStripMenuItem1, this->toolStripMenuItem2, this->toolToolStripMenuItem, this->toolStripMenuItem8});
			this->menuStrip1->Location = System::Drawing::Point(0, 0);
			this->menuStrip1->Name = L"menuStrip1";
			this->menuStrip1->Size = System::Drawing::Size(716, 24);
			this->menuStrip1->TabIndex = 18;
			this->menuStrip1->Text = L"menuStrip1";
			this->menuStrip1->MouseUp += gcnew System::Windows::Forms::MouseEventHandler(this, &Form1::finishWindowDrag);
			this->menuStrip1->MouseDown += gcnew System::Windows::Forms::MouseEventHandler(this, &Form1::startWindowDrag);
			this->menuStrip1->MouseMove += gcnew System::Windows::Forms::MouseEventHandler(this, &Form1::windowDrag);
			// 
			// toolStripMenuItem13
			// 
			this->toolStripMenuItem13->AutoSize = false;
			this->toolStripMenuItem13->Enabled = false;
			this->toolStripMenuItem13->Name = L"toolStripMenuItem13";
			this->toolStripMenuItem13->Size = System::Drawing::Size(37, 20);
			this->toolStripMenuItem13->Text = L"      ";
			// 
			// BottomToolStripPanel
			// 
			this->BottomToolStripPanel->Location = System::Drawing::Point(0, 0);
			this->BottomToolStripPanel->Name = L"BottomToolStripPanel";
			this->BottomToolStripPanel->Orientation = System::Windows::Forms::Orientation::Horizontal;
			this->BottomToolStripPanel->RowMargin = System::Windows::Forms::Padding(3, 0, 0, 0);
			this->BottomToolStripPanel->Size = System::Drawing::Size(0, 0);
			// 
			// TopToolStripPanel
			// 
			this->TopToolStripPanel->Location = System::Drawing::Point(0, 0);
			this->TopToolStripPanel->Name = L"TopToolStripPanel";
			this->TopToolStripPanel->Orientation = System::Windows::Forms::Orientation::Horizontal;
			this->TopToolStripPanel->RowMargin = System::Windows::Forms::Padding(3, 0, 0, 0);
			this->TopToolStripPanel->Size = System::Drawing::Size(0, 0);
			// 
			// RightToolStripPanel
			// 
			this->RightToolStripPanel->Location = System::Drawing::Point(0, 0);
			this->RightToolStripPanel->Name = L"RightToolStripPanel";
			this->RightToolStripPanel->Orientation = System::Windows::Forms::Orientation::Horizontal;
			this->RightToolStripPanel->RowMargin = System::Windows::Forms::Padding(3, 0, 0, 0);
			this->RightToolStripPanel->Size = System::Drawing::Size(0, 0);
			// 
			// LeftToolStripPanel
			// 
			this->LeftToolStripPanel->Location = System::Drawing::Point(0, 0);
			this->LeftToolStripPanel->Name = L"LeftToolStripPanel";
			this->LeftToolStripPanel->Orientation = System::Windows::Forms::Orientation::Horizontal;
			this->LeftToolStripPanel->RowMargin = System::Windows::Forms::Padding(3, 0, 0, 0);
			this->LeftToolStripPanel->Size = System::Drawing::Size(0, 0);
			// 
			// ContentPanel
			// 
			this->ContentPanel->Size = System::Drawing::Size(150, 150);
			// 
			// toolStrip1
			// 
			this->toolStrip1->BackColor = System::Drawing::Color::Transparent;
			this->toolStrip1->BackgroundImage = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"toolStrip1.BackgroundImage")));
			this->toolStrip1->Dock = System::Windows::Forms::DockStyle::Left;
			this->toolStrip1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(10) {this->toolSelecter, this->toolLinker, 
				this->toolStripSeparator1, this->toolStripButton1, this->toolStripButton2, this->toolStripButton3, this->toolStripButton4, this->toolStripButton5, 
				this->toolStripButton6, this->toolStripButton7});
			this->toolStrip1->Location = System::Drawing::Point(0, 24);
			this->toolStrip1->Name = L"toolStrip1";
			this->toolStrip1->Size = System::Drawing::Size(24, 439);
			this->toolStrip1->TabIndex = 94;
			this->toolStrip1->Text = L"toolStrip1";
			// 
			// toolSelecter
			// 
			this->toolSelecter->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image;
			this->toolSelecter->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"toolSelecter.Image")));
			this->toolSelecter->ImageTransparentColor = System::Drawing::Color::Black;
			this->toolSelecter->Name = L"toolSelecter";
			this->toolSelecter->Size = System::Drawing::Size(29, 20);
			this->toolSelecter->Text = L"Selector";
			this->toolSelecter->Click += gcnew System::EventHandler(this, &Form1::menuToolSelecter);
			// 
			// toolLinker
			// 
			this->toolLinker->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image;
			this->toolLinker->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"toolLinker.Image")));
			this->toolLinker->ImageTransparentColor = System::Drawing::Color::Black;
			this->toolLinker->Name = L"toolLinker";
			this->toolLinker->Size = System::Drawing::Size(29, 20);
			this->toolLinker->Text = L"Linker";
			this->toolLinker->Click += gcnew System::EventHandler(this, &Form1::menuToolLinker);
			// 
			// toolStripSeparator1
			// 
			this->toolStripSeparator1->Name = L"toolStripSeparator1";
			this->toolStripSeparator1->Size = System::Drawing::Size(29, 6);
			// 
			// toolStripButton1
			// 
			this->toolStripButton1->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image;
			this->toolStripButton1->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"toolStripButton1.Image")));
			this->toolStripButton1->ImageTransparentColor = System::Drawing::Color::Black;
			this->toolStripButton1->Name = L"toolStripButton1";
			this->toolStripButton1->Size = System::Drawing::Size(29, 20);
			this->toolStripButton1->Text = L"Action";
			this->toolStripButton1->Click += gcnew System::EventHandler(this, &Form1::menuNewAction);
			// 
			// toolStripButton2
			// 
			this->toolStripButton2->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image;
			this->toolStripButton2->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"toolStripButton2.Image")));
			this->toolStripButton2->ImageTransparentColor = System::Drawing::Color::Black;
			this->toolStripButton2->Name = L"toolStripButton2";
			this->toolStripButton2->Size = System::Drawing::Size(29, 20);
			this->toolStripButton2->Text = L"Start Point";
			this->toolStripButton2->Click += gcnew System::EventHandler(this, &Form1::menuNewStart);
			// 
			// toolStripButton3
			// 
			this->toolStripButton3->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image;
			this->toolStripButton3->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"toolStripButton3.Image")));
			this->toolStripButton3->ImageTransparentColor = System::Drawing::Color::Black;
			this->toolStripButton3->Name = L"toolStripButton3";
			this->toolStripButton3->Size = System::Drawing::Size(29, 20);
			this->toolStripButton3->Text = L"End Point";
			this->toolStripButton3->Click += gcnew System::EventHandler(this, &Form1::menuNewEnd);
			// 
			// toolStripButton4
			// 
			this->toolStripButton4->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image;
			this->toolStripButton4->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"toolStripButton4.Image")));
			this->toolStripButton4->ImageTransparentColor = System::Drawing::Color::Black;
			this->toolStripButton4->Name = L"toolStripButton4";
			this->toolStripButton4->Size = System::Drawing::Size(29, 20);
			this->toolStripButton4->Text = L"Signal receiver";
			this->toolStripButton4->Click += gcnew System::EventHandler(this, &Form1::menuNewSignal);
			// 
			// toolStripButton5
			// 
			this->toolStripButton5->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image;
			this->toolStripButton5->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"toolStripButton5.Image")));
			this->toolStripButton5->ImageTransparentColor = System::Drawing::Color::Black;
			this->toolStripButton5->Name = L"toolStripButton5";
			this->toolStripButton5->Size = System::Drawing::Size(29, 20);
			this->toolStripButton5->Text = L"Time signal";
			this->toolStripButton5->Click += gcnew System::EventHandler(this, &Form1::menuNewSignalRecv);
			// 
			// toolStripButton6
			// 
			this->toolStripButton6->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image;
			this->toolStripButton6->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"toolStripButton6.Image")));
			this->toolStripButton6->ImageTransparentColor = System::Drawing::Color::Black;
			this->toolStripButton6->Name = L"toolStripButton6";
			this->toolStripButton6->Size = System::Drawing::Size(29, 20);
			this->toolStripButton6->Text = L"Multiplexer horizontal";
			this->toolStripButton6->Click += gcnew System::EventHandler(this, &Form1::menuNewMultH);
			// 
			// toolStripButton7
			// 
			this->toolStripButton7->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image;
			this->toolStripButton7->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"toolStripButton7.Image")));
			this->toolStripButton7->ImageTransparentColor = System::Drawing::Color::Black;
			this->toolStripButton7->Name = L"toolStripButton7";
			this->toolStripButton7->Size = System::Drawing::Size(29, 20);
			this->toolStripButton7->Text = L"Multiplexer vertical";
			this->toolStripButton7->Click += gcnew System::EventHandler(this, &Form1::menuNewMult);
			// 
			// textBox
			// 
			this->textBox->Location = System::Drawing::Point(626, 99);
			this->textBox->MaxLength = 10;
			this->textBox->Name = L"textBox";
			this->textBox->Size = System::Drawing::Size(61, 20);
			this->textBox->TabIndex = 19;
			this->textBox->KeyPress += gcnew System::Windows::Forms::KeyPressEventHandler(this, &Form1::enterPressed);
			// 
			// placer
			// 
			this->placer->BackColor = System::Drawing::Color::Black;
			this->placer->BackgroundImageLayout = System::Windows::Forms::ImageLayout::Stretch;
			this->placer->Location = System::Drawing::Point(570, 372);
			this->placer->Name = L"placer";
			this->placer->Size = System::Drawing::Size(100, 50);
			this->placer->TabIndex = 95;
			this->placer->TabStop = false;
			this->placer->Visible = false;
			this->placer->MouseMove += gcnew System::Windows::Forms::MouseEventHandler(this, &Form1::mouseFormMove);
			this->placer->MouseDown += gcnew System::Windows::Forms::MouseEventHandler(this, &Form1::mouseStartDrag);
			// 
			// pictureBox1
			// 
			this->pictureBox1->BackgroundImage = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"pictureBox1.BackgroundImage")));
			this->pictureBox1->BackgroundImageLayout = System::Windows::Forms::ImageLayout::Stretch;
			this->pictureBox1->Location = System::Drawing::Point(694, 3);
			this->pictureBox1->Name = L"pictureBox1";
			this->pictureBox1->Size = System::Drawing::Size(18, 18);
			this->pictureBox1->TabIndex = 96;
			this->pictureBox1->TabStop = false;
			this->pictureBox1->Click += gcnew System::EventHandler(this, &Form1::menuClose);
			// 
			// trackBar1
			// 
			this->trackBar1->BackColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(46)), static_cast<System::Int32>(static_cast<System::Byte>(46)), 
				static_cast<System::Int32>(static_cast<System::Byte>(33)));
			this->trackBar1->Location = System::Drawing::Point(693, 24);
			this->trackBar1->Maximum = 5;
			this->trackBar1->Minimum = -5;
			this->trackBar1->Name = L"trackBar1";
			this->trackBar1->Orientation = System::Windows::Forms::Orientation::Vertical;
			this->trackBar1->Size = System::Drawing::Size(45, 439);
			this->trackBar1->TabIndex = 97;
			// 
			// Form1
			// 
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
			this->BackColor = System::Drawing::Color::White;
			this->BackgroundImageLayout = System::Windows::Forms::ImageLayout::Stretch;
			this->ClientSize = System::Drawing::Size(716, 485);
			this->ContextMenuStrip = this->contextMenuStrip1;
			this->Controls->Add(this->toolStrip1);
			this->Controls->Add(this->pictureBox1);
			this->Controls->Add(this->trackBar1);
			this->Controls->Add(this->placer);
			this->Controls->Add(this->statusStrip1);
			this->Controls->Add(this->menuStrip1);
			this->Controls->Add(this->textBox);
			this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::None;
			this->KeyPreview = true;
			this->MainMenuStrip = this->menuStrip1;
			this->MaximizeBox = false;
			this->Name = L"Form1";
			this->Text = L"Editor";
			this->Load += gcnew System::EventHandler(this, &Form1::LoadF);
			this->Click += gcnew System::EventHandler(this, &Form1::mouseFormClk);
			this->KeyUp += gcnew System::Windows::Forms::KeyEventHandler(this, &Form1::keyUp);
			this->MouseMove += gcnew System::Windows::Forms::MouseEventHandler(this, &Form1::mouseFormMove);
			this->KeyDown += gcnew System::Windows::Forms::KeyEventHandler(this, &Form1::keyDown);
			this->contextMenuStrip1->ResumeLayout(false);
			this->statusStrip1->ResumeLayout(false);
			this->statusStrip1->PerformLayout();
			this->menuStrip1->ResumeLayout(false);
			this->menuStrip1->PerformLayout();
			this->toolStrip1->ResumeLayout(false);
			this->toolStrip1->PerformLayout();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->placer))->EndInit();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->pictureBox1))->EndInit();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->trackBar1))->EndInit();
			this->ResumeLayout(false);
			this->PerformLayout();

		}
#pragma endregion
private: char* convertString(String^ other)
	{
		// Pin memory so GC can't move it while native function is called
		pin_ptr<const wchar_t> wch = PtrToStringChars(other);

		// Conversion to char* :
		// Can just convert wchar_t* to char* using one of the 
		// conversion functions such as: 
		// WideCharToMultiByte()
		// wcstombs_s()
		// ... etc
		size_t convertedChars = 0;
		size_t sizeInBytes = ((other->Length + 1) * 2);
		errno_t err = 0;
		char *ch = (char *)malloc(sizeInBytes);

		err = wcstombs_s(&convertedChars, ch, sizeInBytes, wch, sizeInBytes);
		return ch;
	}

private: System::Void Delete() 
		 {
			 this->selected->deleteSelected();
			 this->selected->paint(0);
			 this->project->paint();
			 tool = 0;
			 repaint();
		 }
private: System::Void mouseOn(System::Object^  sender, System::EventArgs^  e) 
		 {
		 }
private: System::Void mouseOff(System::Object^  sender, System::EventArgs^  e) 
		 {
		 }
private: System::Void paintForm(System::Object^  sender, System::Windows::Forms::PaintEventArgs^  e) 
		 {
		 }
private: System::Void MouseDbl(System::Object^  sender, System::EventArgs^  e) 
		 {
			 if (tool==20)
			 {
				 tool=21;
				 this->selected->null();
				 this->selected->addAction(this->project->isAction(sender));
				 this->textBox->Text = this->project->Actions[this->project->isAction(sender)]->getLabel()->Text;
				 this->textBox->Visible = true;
				 this->textBox->Location = this->project->Actions[this->project->isAction(sender)]->getLabel()->Location;
				 this->textBox->BringToFront();
			 }
		 }
private: System::Void mouseTextEO() 
		 {
			 if (tool==21)
			 {
				 this->textBox->Visible = false;
				 this->selected->setText(this->textBox->Text);
				 tool=0;
				 repaint();
			 }
		 }
private: System::Void enterPressed(System::Object^  sender, System::Windows::Forms::KeyPressEventArgs^  e) 
		 {
			 wchar_t t;
			 t=e->KeyChar;
			 if (e->KeyChar == 13)
			 {
				mouseTextEO();
			 }
		 }
private: System::Void mouseFormClk(System::Object^  sender, System::EventArgs^  e) 
		 {
			mouseTextEO();
			switch( tool )
			{   
				case 1:
					tool = 0;
					break;
				case 100:
					this->placer->Visible = false;
					this->project->CreateAction(this->placer->Location.X,this->placer->Location.Y);
					repaint();
					tool = 0;
					break;
				case 101:
					this->placer->Visible = false;
					this->project->CreateStart(this->placer->Location.X,this->placer->Location.Y);
					repaint();
					tool = 0;
					break;
				case 102:
					this->placer->Visible = false;
					this->project->CreateEnd(this->placer->Location.X,this->placer->Location.Y);
					this->hist->AddStep();
					tool = 0;
					break;
				case 103:
					this->placer->Visible = false;
					this->project->CreateSignal(this->placer->Location.X,this->placer->Location.Y);
					repaint();
					tool = 0;
					break;
				case 104:
					this->placer->Visible = false;
					this->project->CreateSignalRecv(this->placer->Location.X,this->placer->Location.Y);
					repaint();
					tool = 0;
					break;
				case 105:
					this->placer->Visible = false;
					this->project->CreateMultiplexerVert(this->placer->Location.X,this->placer->Location.Y);
					repaint();
					tool = 0;
					break;
				case 106:
					this->placer->Visible = false;
					this->project->CreateMultiplexerHort(this->placer->Location.X,this->placer->Location.Y);
					repaint();
					tool = 0;
					break;
				case 107:
					this->placer->Visible = false;
					this->project->CreateComment(this->placer->Location.X,this->placer->Location.Y);
					repaint();
					tool = 0;
					break;
				default:
					tool = 0;
					this->selected->null();
					this->selected->paint(tool);
					break;
			}
		 }
private: System::Void mouseStartDrag(System::Object^  sender, System::Windows::Forms::MouseEventArgs^  e) 
		 {
			 if(flALT) 
			 {
				 switch( tool )
				 {   
					 case 30:
						 this->placer->Visible = false;
						 if (this->project->isAction(sender) > -1)
						 {
							 this->selected->addAction(this->project->isAction(sender));
							 this->selected->paint(tool);
						 }
						 
						 //MousePosition.X=0;
						// MousePosition.Y=0;
						 //this->project->CreateAction(this.mouse.X,Location.Y);
						 repaint();
						 //tool = 0;
						 break;
					 case 101:
						 this->placer->Visible = false;
						 this->project->CreateStart(this->placer->Location.X,this->placer->Location.Y);
						 repaint();
						 tool = 0;
						 break;
				 }

				/*this->placer->Visible = false;
				this->project->CreateAction(e->Location.X,e->Location.Y);
				repaint();*/
			 }
			 		/*this->placer->Visible = false;
					this->project->CreateAction(this->placer->Location.X,this->placer->Location.Y);
					repaint();
					tool = 0;*/
			switch( tool )
			{   
				case 0:
					 if (this->project->isAction(sender) > -1)
					 {
						 this->selected->addAction(this->project->isAction(sender));
						 this->selected->paint(tool);
					 }
					 if (this->project->isLink(sender) > -1)
					 {
						 this->selected->addLink(this->project->isLink(sender));
						 this->selected->paint(tool);
					 }
					 tool=20;
					 X = this->MousePosition.X;
					 Y = this->MousePosition.Y;
					 break;
				case 1:
					 this->selected->addAction(this->project->isAction(sender));
					 this->selected->paint(this->linkType);
					 tool=2;
					 break;
				case 2:
					 this->selected->addAction(this->project->isAction(sender));
					 this->selected->paint(this->linkType);
					 this->project->CreateLink(this->selected->getFirst(),this->selected->getSecond(),this->linkType);
					 this->selected->null();
					 repaint();
					 tool=1;
					 break;
				case 30:
					 this->selected->null();
					 if (this->project->isAction(sender) > -1)
					 {
						 this->selected->addAction(this->project->isAction(sender));
						 this->selected->paint(tool);
					 }
					 if (this->project->isLink(sender) > -1)
					 {
						 this->selected->addLink(this->project->isLink(sender));
						 this->selected->paint(tool);
					 }
					 tool=20;
					 X = this->MousePosition.X;
					 Y = this->MousePosition.Y;
					 break;
				case 300:
					 if (this->project->isAction(sender) > -1)
					 {
						 this->selected->addAction(this->project->isAction(sender));
						 this->selected->paint(tool);
					 }
					 if (this->project->isLink(sender) > -1)
					 {
						 this->selected->addLink(this->project->isLink(sender));
						 this->selected->paint(tool);
					 }
					 tool=320;
					 X = this->MousePosition.X;
					 Y = this->MousePosition.Y;
					 break;
				case 310:
					 tool=312;
					 X = this->MousePosition.X;
					 Y = this->MousePosition.Y;
					 break;
				default:
					 mouseFormClk(sender,e);
					 break;
			}
		 }
private: System::Void mouseOverDrag(System::Object^  sender, System::Windows::Forms::MouseEventArgs^  e) 
		 {
			switch( tool )
			{   
				case 20:
					 tool=30;
					 repaint();
					 break;
				case 312:
					 tool=310;
					 repaint();
					 break;
				case 320:
					 tool=300;
					 repaint();
					 break;
				default:
					 if (tool>=100 && tool<120)
					 {
					 }
					 break;
			}
		 }
private: System::Void mouseDrag(System::Object^  sender, System::Windows::Forms::MouseEventArgs^  e) 
		 {
			 if (tool==20 || tool==312 || tool==320)
			 {
				 int x_c=0,y_c=0;
				 x_c = (this->MousePosition.X - X);
				 X = this->MousePosition.X;
				 y_c = (this->MousePosition.Y - Y);
				 Y = this->MousePosition.Y;
				 this->selected->move(x_c,y_c);
				 this->project->paint();
				 this->Invalidate();
				 this->Update();
			 }
			 if (tool>=100 && tool<120)
			 {
				 this->placer->Visible = true;
				 int x_c=0,y_c=0,x_old=0,y_old=0;
				 x_c = /*20 + */(this->MousePosition.X-this->Location.X);
				 X = this->MousePosition.X;
				 y_c = /*20 + */(this->MousePosition.Y-this->Location.Y);
				 Y = this->MousePosition.Y;

				 this->placer->Location = System::Drawing::Point(x_c,y_c);
			 }
			 else
			 {
				 this->placer->Visible = false;
			 }
		 }
//private: bool collision(System::Windows::Forms::PictureBox^ object1,System::Windows::Forms::PictureBox^ object2) 
//		 {
//			 if (((object1->Location.X < object2->Location.X) && (object1->Location.Y < object2->Location.Y) && ((object1->Location.X + object1->Size.Width) > object2->Location.X) && ((object1->Location.Y + object1->Size.Height) > object2->Location.Y))
//				 || ((object1->Location.X < (object2->Location.X + object2->Size.Width)) && (object1->Location.Y < (object2->Location.Y + object2->Size.Height)) && ((object1->Location.X + object1->Size.Width) > (object2->Location.X + object2->Size.Width)) && ((object1->Location.Y + object1->Size.Height) > (object2->Location.Y + object2->Size.Height)))
//				 || ((object1->Location.X < (object2->Location.X + object2->Size.Width)) && (object1->Location.Y < (object2->Location.Y)) && ((object1->Location.X + object1->Size.Width) > (object2->Location.X + object2->Size.Width)) && ((object1->Location.Y + object1->Size.Height) > (object2->Location.Y)))
//				 || ((object1->Location.X < (object2->Location.X)) && (object1->Location.Y < (object2->Location.Y + object2->Size.Height)) && ((object1->Location.X + object1->Size.Width) > (object2->Location.X)) && ((object1->Location.Y + object1->Size.Height) > (object2->Location.Y + object2->Size.Height)))
//				 || ((object2->Location.X < object1->Location.X) && (object2->Location.Y < object1->Location.Y) && ((object2->Location.X + object2->Size.Width) > object1->Location.X) && ((object2->Location.Y + object2->Size.Height) > object1->Location.Y))
//				 || ((object2->Location.X < (object1->Location.X + object1->Size.Width)) && (object2->Location.Y < (object1->Location.Y + object1->Size.Height)) && ((object2->Location.X + object2->Size.Width) > (object1->Location.X + object1->Size.Width)) && ((object2->Location.Y + object2->Size.Height) > (object1->Location.Y + object1->Size.Height)))
//				 || ((object2->Location.X < (object1->Location.X + object1->Size.Width)) && (object2->Location.Y < (object1->Location.Y)) && ((object2->Location.X + object2->Size.Width) > (object1->Location.X + object1->Size.Width)) && ((object2->Location.Y + object2->Size.Height) > (object1->Location.Y)))
//				 || ((object2->Location.X < (object1->Location.X)) && (object2->Location.Y < (object1->Location.Y + object1->Size.Height)) && ((object2->Location.X + object2->Size.Width) > (object1->Location.X)) && ((object2->Location.Y + object2->Size.Height) > (object1->Location.Y + object1->Size.Height))))
//			 {
//				 return true;
//			 }
//			 return false;
//		 }
//private: bool isPermitted(System::Windows::Forms::PictureBox^ object) 
//		 {
//			 if (!(((0 < object->Location.X) && (0 < object->Location.Y) && ((this->Size.Width) > object->Location.X) && ((this->Size.Height-50) > object->Location.Y))
//				 && ((0 < (object->Location.X + object->Size.Width)) && (0 < (object->Location.Y + object->Size.Height)) && ((this->Size.Width) > (object->Location.X + object->Size.Width)) && ((this->Size.Height-50) > (object->Location.Y + object->Size.Height)))
//				 && ((0 < (object->Location.X + object->Size.Width)) && (0 < (object->Location.Y)) && ((this->Size.Width) > (object->Location.X + object->Size.Width)) && ((this->Size.Height-50) > (object->Location.Y)))
//				 && ((0 < (object->Location.X)) && (0 < (object->Location.Y + object->Size.Height)) && ((this->Size.Width) > (object->Location.X)) && ((this->Size.Height-50) > (object->Location.Y + object->Size.Height)))))
//			 {
//				 return true;
//			 }
//			 if (this->action1->Visible == true)
//			 {
//				 if (collision(this->action1,object))
//				 {
//					 return true;
//				 }
//			 }
//			 if (this->action2->Visible == true)
//			 {
//				 if (collision(this->action2,object))
//				 {
//					 return true;
//				 }
//			 }
//			 if (this->action3->Visible == true)
//			 {
//				 if (collision(this->action3,object))
//				 {
//					 return true;
//				 }
//			 }
//			 if (this->action4->Visible == true)
//			 {
//				 if (collision(this->action4,object))
//				 {
//					 return true;
//				 }
//			 }
//			 if (this->action5->Visible == true)
//			 {
//				 if (collision(this->action5,object))
//				 {
//					 return true;
//				 }
//			 }
//			 if (this->action6->Visible == true)
//			 {
//				 if (collision(this->action6,object))
//				 {
//					 return true;
//				 }
//			 }
//			 if (this->action7->Visible == true)
//			 {
//				 if (collision(this->action7,object))
//				 {
//					 return true;
//				 }
//			 }
//			 return false;
//		 }
private: System::Void menuCopy(System::Object^  sender, System::EventArgs^  e) 
		 {
			 //if (isAction(this->imgActive))
			 //{
				// copyAction();
			 //}
			 //ShowLinks(1);
			 //MoveText(1);
		 }
private: System::Void menuPaste(System::Object^  sender, System::EventArgs^  e) 
		 {
			 //if (isAction(this->imgActive))
			 //{
				// pasteAction();
			 //}
			 //ShowLinks(1);
			 //MoveText(1);
		 }
private: System::Void menuDelete(System::Object^  sender, System::EventArgs^  e) 
		 {
			 Delete();
		 }
private: System::Void menuCut(System::Object^  sender, System::EventArgs^  e) 
		 {
			 //if (isAction(this->imgActive))
			 //{
				// copyAction();
				// deleteAction();
			 //}
			 //ShowLinks(1);
			 //MoveText(1);
		 }
private: System::Void keyPress(System::Object^  sender, System::Windows::Forms::KeyPressEventArgs^  e) 
		 {
			 wchar_t t;
			 t=e->KeyChar;
			 if (e->KeyChar == 8)
			 {
				 Delete();
			 }
		 }
private: System::Void menuToolSelecter(System::Object^  sender, System::EventArgs^  e) 
		 {
			 this->selected->null();
			 this->selected->paint(tool);
			 mouseTextEO();
			 tool = 0;
			 link_stat = 0;
		 }
private: System::Void menuToolLinker(System::Object^  sender, System::EventArgs^  e) 
		 {
			 this->selected->null();
			 this->selected->paint(tool);
			 mouseTextEO();
			 tool = 1;
			 linkType = 1;
		 }
private: System::Void mouseStartResize(System::Object^  sender, System::Windows::Forms::MouseEventArgs^  e) 
		 {
			 if (tool==0 || tool==30)
			 {
				 tool = 20 + this->selected->getResizeTool(sender);
				 X = this->MousePosition.X;
				 Y = this->MousePosition.Y;
			 }
			 if (tool==300)
			 {
				 tool = 320 + this->selected->getResizeTool(sender);
				 X = this->MousePosition.X;
				 Y = this->MousePosition.Y;
			 }
		 }
private: System::Void mouseOverResize(System::Object^  sender, System::Windows::Forms::MouseEventArgs^  e) 
		 {
			 if (tool==21 || tool==22 || tool==23 || tool==24)
			 {
				 tool = 30;
				 this->hist->AddStep();
			 }
			 if (tool==321 || tool==322 || tool==323 || tool==324)
			 {
				 tool = 300;
				 this->hist->AddStep();
			 }
		 }
private: System::Void mouseResize(System::Object^  sender, System::Windows::Forms::MouseEventArgs^  e) 
		 {
			 if (tool==21 || tool==22 || tool==23 || tool==24 || tool==321 || tool==322 || tool==323 || tool==324)
			 {
				 int x=this->MousePosition.X;
				 int y=this->MousePosition.Y;
				 if (tool==21 || tool==321)
				 {
					 this->selected->resize(x-X,y-Y,X-x,Y-y);
				 }
				 if (tool==22 || tool==322)
				 {
					 this->selected->resize(0,y-Y,x-X,Y-y);
				 }
				 if (tool==23 || tool==323)
				 {
					 this->selected->resize(x-X,0,X-x,y-Y);
				 }
				 if (tool==24 || tool==324)
				 {
					 this->selected->resize(0,0,x-X,y-Y);
				 }
				 X = x;
				 Y = y;
				 this->project->paint();
				 this->selected->paint(this->tool);
				 this->Invalidate();
				 this->Update();
			 }
		 }
private: System::Void menuOpenFile(System::Object^  sender, System::EventArgs^  e) 
		 {
			 if (this->openFileDialog1->ShowDialog() == System::Windows::Forms::DialogResult::Cancel)
			 {
				 return;
			 }
			 this->project->OpenFile(this->openFileDialog1->FileName);
			 this->project->paint();
			 this->selected->paint(this->tool);
		 }
private: System::Void menuSaveFile(System::Object^  sender, System::EventArgs^  e) 
		 {
			 if (this->saveFileDialog1->ShowDialog() == System::Windows::Forms::DialogResult::Cancel)
			 {
				 return;
			 }
			 this->project->SaveFile(this->saveFileDialog1->FileName);
		 }
private: System::Void menuClose(System::Object^  sender, System::EventArgs^  e) 
		 {
			 this->Close();
		 }
private: System::Void menuSave(System::Object^  sender, System::EventArgs^  e) 
		 {
			 //if (this->file_name != NULL)
			 //{
				// FILE *stream;
				// // Open for read (will fail if file "crt_fopen.c" does not exist)
				// if( (stream  = fopen( this->file_name, "w" )) != NULL ) // C4996
				// {
				//	 fprintf(stream,"%d, %d, %s",this->action1->Location.X,this->action1->Location.Y,convertString(this->label1->Text));
				//	 if (this->action1->Visible)
				//	 {
				//		 fprintf(stream,", %d\n",1);
				//	 }
				//	 else
				//	 {
				//		 fprintf(stream,", %d\n",0);
				//	 }
				//	 fprintf(stream,"%d, %d, %s",this->action2->Location.X,this->action2->Location.Y,convertString(this->label2->Text));
				//	 if (this->action2->Visible)
				//	 {
				//		 fprintf(stream,", %d\n",1);
				//	 }
				//	 else
				//	 {
				//		 fprintf(stream,", %d\n",0);
				//	 }
				//	 fprintf(stream,"%d, %d, %s",this->action3->Location.X,this->action3->Location.Y,convertString(this->label3->Text));
				//	 if (this->action3->Visible)
				//	 {
				//		 fprintf(stream,", %d\n",1);
				//	 }
				//	 else
				//	 {
				//		 fprintf(stream,", %d\n",0);
				//	 }
				//	 fprintf(stream,"%d, %d, %s",this->action4->Location.X,this->action4->Location.Y,convertString(this->label4->Text));
				//	 if (this->action4->Visible)
				//	 {
				//		 fprintf(stream,", %d\n",1);
				//	 }
				//	 else
				//	 {
				//		 fprintf(stream,", %d\n",0);
				//	 }
				//	 fprintf(stream,"%d, %d, %s",this->action5->Location.X,this->action5->Location.Y,convertString(this->label5->Text));
				//	 if (this->action5->Visible)
				//	 {
				//		 fprintf(stream,", %d\n",1);
				//	 }
				//	 else
				//	 {
				//		 fprintf(stream,", %d\n",0);
				//	 }
				//	 fprintf(stream,"%d, %d, %s",this->action6->Location.X,this->action6->Location.Y,convertString(this->label6->Text));
				//	 if (this->action6->Visible)
				//	 {
				//		 fprintf(stream,", %d\n",1);
				//	 }
				//	 else
				//	 {
				//		 fprintf(stream,", %d\n",0);
				//	 }
				//	 fprintf(stream,"%d, %d, %s",this->action7->Location.X,this->action7->Location.Y,convertString(this->label7->Text));
				//	 if (this->action7->Visible)
				//	 {
				//		 fprintf(stream,", %d\n",1);
				//	 }
				//	 else
				//	 {
				//		 fprintf(stream,", %d\n",0);
				//	 }
				//	 fprintf(stream,"%d\n",this->link_num);
				//	 for (int i=0;i<this->link_num;i++)
				//	 {
				//		 fprintf(stream,"%d-%d\n",getActionNum(this->link_from[i]),getActionNum(this->link_to[i]));
				//	 }
				// }
				// fclose(stream);
			 //}
		 }
private: System::Void menuExportJpg(System::Object^  sender, System::EventArgs^  e) 
		 {
			 if (this->saveFileDialog2->ShowDialog() == System::Windows::Forms::DialogResult::Cancel)
			 {
				 return;
			 }

			 this->menuStrip1->Visible = false;
			 this->toolStrip1->Visible = false;
			 this->statusStrip1->Visible = false;
			 this->trackBar1->Visible = false;
			 //this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::None;
			 for (int i=0;i<this->project->getLMax();i++)
			 {
				 this->project->Links[i]->getArrow()->BringToFront();
			 }
			 for (int i=0;i<this->project->getAMax();i++)
			 {
				this->project->Actions[i]->getActionImg()->SendToBack();
				this->project->Actions[i]->getLabel()->SendToBack();
			 }

			 System::Drawing::Bitmap ^b = gcnew System::Drawing::Bitmap(this->Width,this->Height);
			 System::Drawing::Rectangle r(0,0,this->Width,this->Height);
			 this->DrawToBitmap(b,r);
			 b->Save(this->saveFileDialog2->FileName);

			 this->menuStrip1->Visible = true;
			 this->toolStrip1->Visible = true;
			 this->statusStrip1->Visible = true;
			 this->trackBar1->Visible = true;
			 for (int i=0;i<this->project->getLMax();i++)
			 {
				 this->project->Links[i]->getArrow()->SendToBack();
			 }
			 for (int i=0;i<this->project->getAMax();i++)
			 {
				this->project->Actions[i]->getActionImg()->BringToFront();
				this->project->Actions[i]->getLabel()->BringToFront();
			 }
			 this->Invalidate();
			 //this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::FixedSingle;
		 }
private: System::Void menuNewAction(System::Object^  sender, System::EventArgs^  e) 
		 {
			 this->selected->null();
			 this->selected->paint(tool);
			 X = this->MousePosition.X;
			 Y = this->MousePosition.Y;
			 this->placer->BringToFront();
			 this->placer->BackgroundImage = this->project->res->action;
			 this->placer->Location = System::Drawing::Point(this->MousePosition.X-this->Location.X,this->MousePosition.Y-this->Location.Y);
			 this->placer->Size = System::Drawing::Size(150,75);
			 tool=100;
		 }
private: System::Void menuNewStart(System::Object^  sender, System::EventArgs^  e) 
		 {
			 this->selected->null();
			 this->selected->paint(tool);
			 X = this->MousePosition.X;
			 Y = this->MousePosition.Y;
			 this->placer->BringToFront();
			 this->placer->BackgroundImage = this->project->res->start;
			 this->placer->Location = System::Drawing::Point(this->MousePosition.X-this->Location.X,this->MousePosition.Y-this->Location.Y);
			 this->placer->Size = System::Drawing::Size(30,30);
			 tool=101;
		 }
private: System::Void menuNewEnd(System::Object^  sender, System::EventArgs^  e) 
		 {
			 X = this->MousePosition.X;
			 Y = this->MousePosition.Y;
			 this->placer->BringToFront();
			 this->placer->BackgroundImage = this->project->res->end;
			 this->placer->Location = System::Drawing::Point(this->MousePosition.X-this->Location.X,this->MousePosition.Y-this->Location.Y);
			 this->placer->Size = System::Drawing::Size(30,30);
			 tool=102;
		 }
private: System::Void menuNewSignal(System::Object^  sender, System::EventArgs^  e) 
		 {
			 this->selected->null();
			 this->selected->paint(tool);
			 X = this->MousePosition.X;
			 Y = this->MousePosition.Y;
			 this->placer->BringToFront();
			 this->placer->BackgroundImage = this->project->res->signal;
			 this->placer->Location = System::Drawing::Point(this->MousePosition.X-this->Location.X,this->MousePosition.Y-this->Location.Y);
			 this->placer->Size = System::Drawing::Size(150,75);
			 tool=103;
		 }
private: System::Void menuNewSignalRecv(System::Object^  sender, System::EventArgs^  e) 
		 {
			 this->selected->null();
			 this->selected->paint(tool);
			 X = this->MousePosition.X;
			 Y = this->MousePosition.Y;
			 this->placer->BringToFront();
			 this->placer->BackgroundImage = this->project->res->signal_emm;
			 this->placer->Location = System::Drawing::Point(this->MousePosition.X-this->Location.X,this->MousePosition.Y-this->Location.Y);
			 this->placer->Size = System::Drawing::Size(30,50);
			 tool=104;
		 }
private: System::Void menuNewMult(System::Object^  sender, System::EventArgs^  e) 
		 {
			 this->selected->null();
			 this->selected->paint(tool);
			 X = this->MousePosition.X;
			 Y = this->MousePosition.Y;
			 this->placer->BringToFront();
			 this->placer->BackgroundImage = this->project->res->link;
			 this->placer->Location = System::Drawing::Point(this->MousePosition.X-this->Location.X,this->MousePosition.Y-this->Location.Y);
			 this->placer->Size = System::Drawing::Size(8,120);
			 tool=105;
		 }
private: System::Void menuNewMultH(System::Object^  sender, System::EventArgs^  e) 
		 {
			 this->selected->null();
			 this->selected->paint(tool);
			 X = this->MousePosition.X;
			 Y = this->MousePosition.Y;
			 this->placer->BringToFront();
			 this->placer->BackgroundImage = this->project->res->link;
			 this->placer->Location = System::Drawing::Point(this->MousePosition.X-this->Location.X,this->MousePosition.Y-this->Location.Y);
			 this->placer->Size = System::Drawing::Size(120,8);
			 tool=106;
		 }
private: System::Void menuNewTextComment(System::Object^  sender, System::EventArgs^  e) 
		 {
			 this->selected->null();
			 this->selected->paint(tool);
			 X = this->MousePosition.X;
			 Y = this->MousePosition.Y;
			 this->placer->BringToFront();
			 this->placer->BackgroundImage = this->project->res->link;
			 this->placer->Location = System::Drawing::Point(this->MousePosition.X-this->Location.X,this->MousePosition.Y-this->Location.Y);
			 this->placer->Size = System::Drawing::Size(70,30);
			 tool=107;
		 }
private: System::Void menuToolLinkerC(System::Object^  sender, System::EventArgs^  e) 
		 {
			 this->selected->null();
			 this->selected->paint(tool);
			 mouseTextEO();
			 tool = 1;
			 linkType = 2;
		 }
private: System::Void contextMenuDelete(System::Object^  sender, System::EventArgs^  e) 
		 {
			 Delete();
		 }
private: System::Void LoadF(System::Object^  sender, System::EventArgs^  e) 
{
		this->project = gcnew Scene();
		this->selected = gcnew Selector(this->project);
		this->DoubleBuffered = true;
		this->textBox->Visible = false;
		this->project->Preload(contextMenuStrip1);
		for (int i=0;i<this->project->getAMax();i++)
		{
			this->Controls->Add(project->Actions[i]->getActionImg());
			this->Controls->Add(project->Actions[i]->getLabel());

			this->project->Actions[i]->getActionImg()->MouseLeave += gcnew System::EventHandler(this, &Form1::mouseOff);
			this->project->Actions[i]->getActionImg()->MouseMove += gcnew System::Windows::Forms::MouseEventHandler(this, &Form1::mouseDrag);
			this->project->Actions[i]->getActionImg()->MouseDown += gcnew System::Windows::Forms::MouseEventHandler(this, &Form1::mouseStartDrag);
			this->project->Actions[i]->getActionImg()->MouseUp += gcnew System::Windows::Forms::MouseEventHandler(this, &Form1::mouseOverDrag);
			this->project->Actions[i]->getActionImg()->MouseEnter += gcnew System::EventHandler(this, &Form1::mouseOn);
			this->project->Actions[i]->getActionImg()->DoubleClick += gcnew System::EventHandler(this, &Form1::MouseDbl);

			this->project->Actions[i]->getLabel()->MouseLeave += gcnew System::EventHandler(this, &Form1::mouseOff);
			this->project->Actions[i]->getLabel()->MouseMove += gcnew System::Windows::Forms::MouseEventHandler(this, &Form1::mouseDrag);
			this->project->Actions[i]->getLabel()->MouseDown += gcnew System::Windows::Forms::MouseEventHandler(this, &Form1::mouseStartDrag);
			this->project->Actions[i]->getLabel()->MouseUp += gcnew System::Windows::Forms::MouseEventHandler(this, &Form1::mouseOverDrag);
			this->project->Actions[i]->getLabel()->MouseEnter += gcnew System::EventHandler(this, &Form1::mouseOn);
			this->project->Actions[i]->getLabel()->DoubleClick += gcnew System::EventHandler(this, &Form1::MouseDbl);
		}
		for (int i=0;i<this->project->getLMax();i++)
		{
			this->Controls->Add(this->project->Links[i]->getSr());
			this->Controls->Add(this->project->Links[i]->getVert());
			this->Controls->Add(this->project->Links[i]->getHort());
			this->Controls->Add(this->project->Links[i]->getArrow());

			this->project->Links[i]->getSr()->MouseDown += gcnew System::Windows::Forms::MouseEventHandler(this, &Form1::mouseStartDrag);
			this->project->Links[i]->getVert()->MouseDown += gcnew System::Windows::Forms::MouseEventHandler(this, &Form1::mouseStartDrag);
			this->project->Links[i]->getHort()->MouseDown += gcnew System::Windows::Forms::MouseEventHandler(this, &Form1::mouseStartDrag);
			this->project->Links[i]->getArrow()->MouseDown += gcnew System::Windows::Forms::MouseEventHandler(this, &Form1::mouseStartDrag);
		}
		this->project->paint();
		this->hist = gcnew History(this->project,this->selected,this->contextMenuStrip1);
		for (int i=0;i<this->project->getAMax();i++)
		{
			this->Controls->Add(this->selected->SelectorUpLeft[i]);
			this->Controls->Add(this->selected->SelectorUpRight[i]);
			this->Controls->Add(this->selected->SelectorDownLeft[i]);
			this->Controls->Add(this->selected->SelectorDownRight[i]);

			this->selected->SelectorUpLeft[i]->MouseDown += gcnew System::Windows::Forms::MouseEventHandler(this, &Form1::mouseStartResize);
			this->selected->SelectorUpRight[i]->MouseDown += gcnew System::Windows::Forms::MouseEventHandler(this, &Form1::mouseStartResize);
			this->selected->SelectorDownLeft[i]->MouseDown += gcnew System::Windows::Forms::MouseEventHandler(this, &Form1::mouseStartResize);
			this->selected->SelectorDownRight[i]->MouseDown += gcnew System::Windows::Forms::MouseEventHandler(this, &Form1::mouseStartResize);

			this->selected->SelectorUpLeft[i]->MouseUp += gcnew System::Windows::Forms::MouseEventHandler(this, &Form1::mouseOverResize);
			this->selected->SelectorUpRight[i]->MouseUp += gcnew System::Windows::Forms::MouseEventHandler(this, &Form1::mouseOverResize);
			this->selected->SelectorDownLeft[i]->MouseUp += gcnew System::Windows::Forms::MouseEventHandler(this, &Form1::mouseOverResize);
			this->selected->SelectorDownRight[i]->MouseUp += gcnew System::Windows::Forms::MouseEventHandler(this, &Form1::mouseOverResize);

			this->selected->SelectorUpLeft[i]->MouseMove += gcnew System::Windows::Forms::MouseEventHandler(this, &Form1::mouseResize);
			this->selected->SelectorUpRight[i]->MouseMove += gcnew System::Windows::Forms::MouseEventHandler(this, &Form1::mouseResize);
			this->selected->SelectorDownLeft[i]->MouseMove += gcnew System::Windows::Forms::MouseEventHandler(this, &Form1::mouseResize);
			this->selected->SelectorDownRight[i]->MouseMove += gcnew System::Windows::Forms::MouseEventHandler(this, &Form1::mouseResize);
		}
		this->selected->paint(0);
}
private: System::Void mouseFormMove(System::Object^  sender, System::Windows::Forms::MouseEventArgs^  e) 
{
		 if (tool>=100 && tool<120)
		 {
			 this->placer->Visible = true;
			 int x_c=0,y_c=0,x_old=0,y_old=0;
			 x_c = /*20 + */(this->MousePosition.X-this->Location.X);
			 X = this->MousePosition.X;
			 y_c = /*20 + */(this->MousePosition.Y-this->Location.Y);
			 Y = this->MousePosition.Y;

			 this->placer->Location = System::Drawing::Point(x_c,y_c);
			 //this->Invalidate();
			 //this->Update();
		 }
		 else
		 {
			 this->placer->Visible = false;
		 }
}
private: System::Void startWindowDrag(System::Object^  sender, System::Windows::Forms::MouseEventArgs^  e) 
{
		 if (tool==0)
		 {
			 tool=200;
			 X = this->MousePosition.X;
			 Y = this->MousePosition.Y;
		 }
}
private: System::Void finishWindowDrag(System::Object^  sender, System::Windows::Forms::MouseEventArgs^  e) 
{
		 if (tool==200)
		 {
			 tool=0;
		 }
}
private: System::Void windowDrag(System::Object^  sender, System::Windows::Forms::MouseEventArgs^  e) 
{
		 if (tool==200)
		 {
			 int x_c=0,y_c=0;
			 x_c = this->Location.X + (this->MousePosition.X-X);
			 X = this->MousePosition.X;
			 y_c = this->Location.Y + (this->MousePosition.Y-Y);
			 Y = this->MousePosition.Y;
			 this->Location = System::Drawing::Point(x_c,y_c);
		 }
}
private: System::Void keyDown(System::Object^  sender, System::Windows::Forms::KeyEventArgs^  e) 
{
	if(e->Modifiers == System::Windows::Forms::Keys::Alt) 
		flALT = true;
	 if (e->Control)
	 {
		 if (e->KeyCode == System::Windows::Forms::Keys::Z)
		 {
			 this->hist->DownInHistory();
			 this->hist->InvolveHistory();
			 this->project->paint();
			 this->selected->paint(tool);
		 }
		 if (e->KeyCode == System::Windows::Forms::Keys::Y)
		 {
			 this->hist->UpInHistory();
			 this->hist->InvolveHistory();
			 this->project->paint();
			 this->selected->paint(tool);
		 }
		 tool = 300;
	 }
	 if (e->KeyCode == System::Windows::Forms::Keys::Delete)
	 {
		 this->selected->deleteSelected();
		 this->project->paint();
		 this->selected->paint(tool);
	 }
}
private: System::Void keyUp(System::Object^  sender, System::Windows::Forms::KeyEventArgs^  e) 
{ 
	flALT = false;
	 if (tool==300)
	 {
		 tool = 310;
	 }
}
private: System::Void DoUndo(System::Object^  sender, System::EventArgs^  e) 
{
	this->hist->DownInHistory();
	this->hist->InvolveHistory();
	toolStripEnabled();
}
private: System::Void DoRedo(System::Object^  sender, System::EventArgs^  e) 
{
	this->hist->UpInHistory();
	this->hist->InvolveHistory();
	toolStripEnabled();
}
private: System::Void repaint() 
{
	this->hist->AddStep();
	this->project->paint();
	this->selected->paint(tool);
	toolStripEnabled();
}
private: System::Void toolStripEnabled() 
{
	if (this->hist->get('p') > 0)
	{
		this->undoToolStripMenuItem->Enabled = true;
	}
	else
	{
		this->undoToolStripMenuItem->Enabled = false;
	}
	if (this->hist->get('p') < (this->hist->get('n')-1))
	{
		this->redoToolStripMenuItem->Enabled = true;
	}
	else
	{
		this->redoToolStripMenuItem->Enabled = false;
	}
}
};
}
